package com.telecomyt.jwportal.activity.work;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.haibin.calendarview.Calendar;
import com.haibin.calendarview.CalendarView;
import com.telecomyt.jwportal.R;
import com.telecomyt.jwportal.base.BaseActivity;
import com.telecomyt.jwportal.base.BasePresenter;
import com.telecomyt.jwportal.utils.SignCalendar;
import com.telecomyt.jwportal.utils.ToastUtils;
import com.telecomyt.jwportal.widget.FraToolBar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @date: 2020/9/15
 * @author: chengDa
 * @description: 值班信息
 */
public class WorkLogActivity extends BaseActivity {

    @BindView(R.id.mFraToolBar)
    FraToolBar mFraToolBar;
    @BindView(R.id.calendarView)
    CalendarView calendarView;
    @BindView(R.id.mTvMonth)
    TextView mTvMonth;
    @BindView(R.id.mTvLast)
    TextView mTvLast;
    @BindView(R.id.mTvNext)
    TextView mTvNext;
    @BindView(R.id.mSignCalendar)
    SignCalendar mSignCalendar;
    List<String> list = new ArrayList<String>();
    public static void start(Context context) {
        Intent starter = new Intent(context, WorkLogActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_work_log;
    }

    @Override
    protected void initView() {
        mFraToolBar.setLeftFinish(this);
        mTvMonth.setText(String.format("%s-%s", calendarView.getCurYear(), calendarView.getCurMonth()));
        calendarView.setOnMonthChangeListener(new CalendarView.OnMonthChangeListener() {//日期改变
            @Override
            public void onMonthChange(int year, int month) {
                mTvMonth.setText(String.format("%s-%s", year, month));
            }
        });
        calendarView.setOnCalendarSelectListener(new CalendarView.OnCalendarSelectListener() {//日期选择
            @Override
            public void onCalendarOutOfRange(Calendar calendar) {

            }

            @Override
            public void onCalendarSelect(Calendar calendar, boolean isClick) {
                if (isClick) {
                    ToastUtils.showShort(String.format("当前点击%s年%s月%s日", calendar.getYear(), calendar.getMonth(), calendar.getDay()));
                }

            }
        });
        mSignCalendar.setOnCalendarClickListener(new SignCalendar.OnCalendarClickListener() {//点击回调
            @Override
            public void onCalendarClick(int row, int col, String dateFormat) {
                ToastUtils.showShort(dateFormat);
            }
        });
        mSignCalendar.setOnCalendarDateChangedListener(new SignCalendar.OnCalendarDateChangedListener() {//日历翻页回调

            @Override
            public void onCalendarDateChanged(int year, int month) {

                ToastUtils.showShort("翻页了");
            }
        });
//        list.add("2020-9-12");
//        list.add("2020-9-13");
//        list.add("");
//        list.add(date);
        mSignCalendar.addMark("2020-9-14", 0);
    }

    @Override
    protected void initData() {


    }

    @Override
    protected BasePresenter creatPresenter() {
        return null;
    }


    @OnClick({R.id.mTvLast, R.id.mTvNext})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.mTvLast:
                calendarView.scrollToPre();
                mSignCalendar.lastMonth();
                break;
            case R.id.mTvNext:
                calendarView.scrollToNext();
                mSignCalendar.nextMonth();
                break;
        }
    }


}